import 'package:api/pages/provider/getX/demo/count/count_page.dart';
import 'package:api/pages/provider/getX/demo/route/route_home.dart';
import 'package:api/pages/provider/getX/demo/shop/shop_main_page.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

void main() => runApp(PrividerApp());

class PrividerApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // 使用getX第一步
    return GetMaterialApp(
      title: 'Provider学习',
      routes: {
        "/route": (context) => RouteHomePage(),
        "/count": (context) => CountHomePage(),
        "/shop": (context) => ShopMainPage(),
      },
      home: myHomePage(),
    );
  }
}

class myHomePage extends StatefulWidget {
  @override
  _myHomePageState createState() => _myHomePageState();
}

class _myHomePageState extends State<myHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('首页'),
      ),
      body: Container(
        width: double.infinity,
        height: double.infinity,
        child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            children: [
              ElevatedButton(
                onPressed: () {
                  Get.toNamed("/route");
                },
                child: Text("getx 路由"),
              ),
              ElevatedButton(
                onPressed: () {
                  Get.toNamed("/count");
                },
                child: Text("getx 计数"),
              ),
              ElevatedButton(
                onPressed: () {
                  Get.toNamed("/shop");
                },
                child: Text("getx 商城"),
              ),
            ]),
      ),
    );
  }
}
